﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbIdPair : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbIdPair(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbIdPair obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbIdPair()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbIdPair(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public OdDbIdPair() : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_0(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbIdPair(OdDbIdPair source) : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_1(OdDbIdPair.getCPtr(source)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbIdPair(OdDbObjectId key) : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_2(OdDbObjectId.getCPtr(key)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbIdPair(OdDbObjectId key, OdDbObjectId value, bool cloned, bool ownerXlated, bool primary) : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_3(OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value), cloned, ownerXlated, primary), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbIdPair(OdDbObjectId key, OdDbObjectId value, bool cloned, bool ownerXlated) : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_4(OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value), cloned, ownerXlated), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbIdPair(OdDbObjectId key, OdDbObjectId value, bool cloned) : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_5(OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value), cloned), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbIdPair(OdDbObjectId key, OdDbObjectId value) : this(TD_DbPINVOKE.new_OdDbIdPair__SWIG_6(OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbObjectId key()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbIdPair_key(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbObjectId value()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbIdPair_value(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isCloned()
		{
			bool result = TD_DbPINVOKE.OdDbIdPair_isCloned(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isPrimary()
		{
			bool result = TD_DbPINVOKE.OdDbIdPair_isPrimary(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isOwnerXlated()
		{
			bool result = TD_DbPINVOKE.OdDbIdPair_isOwnerXlated(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbIdPair set(OdDbObjectId key, OdDbObjectId value, bool cloned, bool ownerXlated, bool primary)
		{
			OdDbIdPair result = new OdDbIdPair(TD_DbPINVOKE.OdDbIdPair_set__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value), cloned, ownerXlated, primary), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbIdPair set(OdDbObjectId key, OdDbObjectId value, bool cloned, bool ownerXlated)
		{
			OdDbIdPair result = new OdDbIdPair(TD_DbPINVOKE.OdDbIdPair_set__SWIG_1(this.swigCPtr, OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value), cloned, ownerXlated), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbIdPair set(OdDbObjectId key, OdDbObjectId value, bool cloned)
		{
			OdDbIdPair result = new OdDbIdPair(TD_DbPINVOKE.OdDbIdPair_set__SWIG_2(this.swigCPtr, OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value), cloned), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbIdPair set(OdDbObjectId key, OdDbObjectId value)
		{
			OdDbIdPair result = new OdDbIdPair(TD_DbPINVOKE.OdDbIdPair_set__SWIG_3(this.swigCPtr, OdDbObjectId.getCPtr(key), OdDbObjectId.getCPtr(value)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setKey(OdDbObjectId key)
		{
			TD_DbPINVOKE.OdDbIdPair_setKey(this.swigCPtr, OdDbObjectId.getCPtr(key));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setValue(OdDbObjectId value)
		{
			TD_DbPINVOKE.OdDbIdPair_setValue(this.swigCPtr, OdDbObjectId.getCPtr(value));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setCloned(bool cloned)
		{
			TD_DbPINVOKE.OdDbIdPair_setCloned(this.swigCPtr, cloned);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setPrimary(bool primary)
		{
			TD_DbPINVOKE.OdDbIdPair_setPrimary(this.swigCPtr, primary);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setOwnerXlated(bool ownerXlated)
		{
			TD_DbPINVOKE.OdDbIdPair_setOwnerXlated(this.swigCPtr, ownerXlated);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;
	}
}
